﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data.SqlClient;
using System.Data;

namespace DataAccessLayer
{
    internal class SqlDatabase : Database
    {
        #region Member Variables

        private string m_szConnection = string.Empty;
        private int m_iCommandTimeout = 1;
        private SqlConnection m_oConnection = null;

        #endregion

        #region Constructors 

        internal SqlDatabase()
        {

        }

        internal SqlDatabase(string szConnection)
        {


        }

        internal SqlDatabase(string szConnection, int iCommandTimeout)
        {

        }


        #endregion

        #region Properties 

        public override string ConnectionString
        {
            set
            {
                if (value.Trim() == string.Empty)
                {
                    throw new Exception("Connection String cannot be empty");
                }
                m_szConnection = value;
            }
        }

        public override int CommandTimeout
        {
            set
            {
                m_iCommandTimeout = value;
            }
        }


        #endregion

        #region ExecuteQuery 

        public override DataSet ExecuteQuery(string szQuery, string szTableName)
        {
            throw new NotImplementedException();
        }

        public override DataSet ExecuteQuery(string[] szQuery, string[] szTableName)
        {
            throw new NotImplementedException();
        }

        public override DataSet ExecuteQuery(string szQuery)
        {
            throw new NotImplementedException();
        }

        public override DataSet ExecuteQuery(string[] szQuery)
        {
            throw new NotImplementedException();
        }

        #endregion

        #region ExecuteScalar 

        public override object ExecuteScalar(string szQuery)
        {
            throw new NotImplementedException();
        }

        #endregion

        #region ExecuteNonQuery 

        public override int ExecuteNonQuery(string szQuery)
        {
            throw new NotImplementedException();
        }

        public override int ExecuteNonQuery(string[] szQuery)
        {
            throw new NotImplementedException();
        }

        public override int ExecuteNonQuery(string[] szQuery, bool bTranasactionRequired)
        {
            throw new NotImplementedException();
        }

        #endregion

        #region Connection 

        public override ConnectionState ConnectionStatus()
        {
            return m_oConnection.State;
        }

        private void OpenConnection()
        {
            if (m_oConnection != null)
            {
                m_oConnection.Open();
            }
            else
            {
                throw new Exception("Connection object not created");
            }
        }

        private void CloseConnection()
        {
            if (m_oConnection.State != ConnectionState.Closed)
            {
                m_oConnection.Close();
            }
        }

        #endregion

        #region Dispose 

        public override void Dispose()
        {
            CloseConnection();
        }

        #endregion

    }// end of class
}// end of namespace
